package com.example.zhihu.entity;

import com.alibaba.fastjson.annotation.JSONField;
import java.util.List;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author t-zhaoheng
 * @since 2022/4/16
 * 从知乎的热榜上取出的实体类
 */
@NoArgsConstructor
@Data
public class HotData {

  @JSONField(name = "data")
  private List<DataDTO> data;
  @JSONField(name = "paging")
  private PagingDTO paging;
  @JSONField(name = "fresh_text")
  private String freshText;
  @JSONField(name = "display_num")
  private Integer displayNum;

  @NoArgsConstructor
  @Data
  public static class PagingDTO {

    @JSONField(name = "is_end")
    private Boolean isEnd;
    @JSONField(name = "next")
    private String next;
    @JSONField(name = "previous")
    private String previous;
  }

  /**
   * 知乎热榜数据的主要实体对象部分
   */
  @NoArgsConstructor
  @Data
  public static class DataDTO {

    @JSONField(name = "type")
    private String type;
    @JSONField(name = "style_type")
    private String styleType;
    @JSONField(name = "id")
    private String id;
    @JSONField(name = "card_id")
    private String cardId;
    @JSONField(name = "target")
    private DataDTO.TargetDTO target;
    @JSONField(name = "attached_info")
    private String attachedInfo;
    @JSONField(name = "detail_text")
    private String detailText;
    @JSONField(name = "trend")
    private Integer trend;
    @JSONField(name = "debut")
    private Boolean debut;
    @JSONField(name = "children")
    private List<ChildrenDTO> children;

    @NoArgsConstructor
    @Data
    public static class TargetDTO {

      @JSONField(name = "id")
      private Integer id;
      @JSONField(name = "title")
      private String title;
      @JSONField(name = "url")
      private String url;
      @JSONField(name = "type")
      private String type;
      @JSONField(name = "created")
      private Long created;
      @JSONField(name = "answer_count")
      private Integer answerCount;
      @JSONField(name = "follower_count")
      private Integer followerCount;
      @JSONField(name = "author")
      private DataDTO.TargetDTO.AuthorDTO author;
      @JSONField(name = "bound_topic_ids")
      private List<Integer> boundTopicIds;
      @JSONField(name = "comment_count")
      private Integer commentCount;
      @JSONField(name = "is_following")
      private Boolean isFollowing;
      @JSONField(name = "excerpt")
      private String excerpt;

      @NoArgsConstructor
      @Data
      public static class AuthorDTO {

        @JSONField(name = "type")
        private String type;
        @JSONField(name = "user_type")
        private String userType;
        @JSONField(name = "id")
        private String id;
        @JSONField(name = "url_token")
        private String urlToken;
        @JSONField(name = "url")
        private String url;
        @JSONField(name = "name")
        private String name;
        @JSONField(name = "headline")
        private String headline;
        @JSONField(name = "avatar_url")
        private String avatarUrl;
      }
    }

    @NoArgsConstructor
    @Data
    public static class ChildrenDTO {

      @JSONField(name = "type")
      private String type;
      @JSONField(name = "thumbnail")
      private String thumbnail;
    }
  }
}
